﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HotelBookingSystem.DataBaseStuff
{
    abstract class HotelFunctionalities
    {
        public static bool RoomTypeEmpty(_Room[] roomType)
        {
            bool checker = true;
            foreach (_Room el in roomType)
            {
                if (el.full == false)
                {
                    checker = false; break;
                }
            }
            if (checker)
                return true;
            else
                return false;
        }
        public static ResultRoom CheckForRoom(_Room[] roomType)
        {
            List<RoomInfo> roomsInfo = new List<RoomInfo>();
            if (RoomTypeEmpty(roomType))
            {
                return new ResultRoom(roomsInfo, null);
            }

            string result = "";
            uint rmNum = 0;
            uint periodCount = 0;

            foreach (_Room el in roomType)//=======================
            {
                ++rmNum;
                if (el.full == true)
                {
                    roomsInfo.Add(new RoomInfo(rmNum, 0, periodCount));
                    continue;
                }
                uint curPeriods = 0;
                foreach (DateTime timeEl in el.startDates)//=======================
                {
                    result += (++periodCount).ToString() + ". " + el.startDates[(int)curPeriods].ToShortDateString() +
                        " - " + el.endDates[(int)curPeriods].ToShortDateString() + "\n";
                    if (periodCount > 8)
                    {
                        roomsInfo.Add(new RoomInfo(rmNum, curPeriods + 1, periodCount));
                        return new ResultRoom(roomsInfo, result);
                    }
                    roomsInfo.Add(new RoomInfo(rmNum, curPeriods + 1, periodCount));
                    ++curPeriods;
                }
            }

            return new ResultRoom(roomsInfo, result);
        }

    }
}